using namespace std;
#include <iostream>
#include <cstdlib>
#include <string>
//#include <vector>

int main()
{
    std::string s, s1;
    cout << "Введите скобочную последовательность:";
    cin >> s;
    s1 = "";
    for (char c : s)
    {
        if (c == 40)
            s1 = s1 + c;
        if (c == 41)
            if (s1.length() > 0)
            {
                s1.pop_back();
                if (s1 == "(")
                    s1 = s1.length();
            }
         if (c == 123)
            s1 = s1 + c;
        if (c == 125)
            if (s1.length() > 0)
            {
                s1.pop_back();
                if (s1 == "{")
                    s1 = s1.length();
            }
         if (c == 91)
            s1 = s1 + c;
        if (c == 93)
            if (s1.length() > 0)
            {
                s1.pop_back();
                if (s1 == "[")
                    s1 = s1.length();
            }
         if (c ==60 )
            s1 = s1 + c;
        if (c ==62 )
            if (s1.length() > 0)
            {
                s1.pop_back();
                if (s1 == "<")
                    s1 = s1.length();
            }   
    }
    if (s1 == "")
        cout << "True";
    else
        cout << "False";
}




